package com.better.common.utils;

import com.better.common.exception.DescribeException;
import com.better.common.exception.ExceptionEnum;
import com.better.common.jwtauth.secruity.JWTUserDetails;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * Created by Administrator on 2017/12/11.
 */
public class SessionUtils {

    public static JWTUserDetails getUserInfo(){
        try {
            JWTUserDetails jwtUserDetails = (JWTUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
            return jwtUserDetails;
        }catch (Exception e){
            throw  new BadCredentialsException("未授权.没有登录或者登录超时");
        }

    }



}
